/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Statistiques.java
 *
 * Created on 15 mars 2011, 23:35:46
 */

package jade.ui;

import jade.sql.SqlToAbstractTableModel;
import javax.swing.table.AbstractTableModel;

/**
 * Fenêtre de statistiques sur les parties déjà jouées
 */
public class Statistiques extends javax.swing.JFrame {

    AbstractTableModel modelTableSports = null;
    AbstractTableModel modelTableSeries = null;


    /** Creates new form Statistiques */
    public Statistiques() {

        // Récupère les statistiques à partir de la BDD
        modelTableSports = new SqlToAbstractTableModel("SELECT NOM, NB_TROUVE, (NB_JOUE - NB_TROUVE) as NB_PERD FROM SPORTS ORDER BY NB_TROUVE DESC");
        modelTableSeries = new SqlToAbstractTableModel("SELECT NOM, NB_TROUVE, (NB_JOUE - NB_TROUVE) as NB_PERD FROM SERIES ORDER BY NB_TROUVE DESC");
        
        initComponents();
        this.setLocationRelativeTo(this.getParent());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableSports = new javax.swing.JTable(modelTableSports);
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableSeries = new javax.swing.JTable(modelTableSeries);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Statistiques du programme JADE");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText("Statistiques JADE");

        jTableSports.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(jTableSports);

        jTabbedPane1.addTab("Sports", jScrollPane1);

        jTableSeries.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(jTableSeries);

        jTabbedPane1.addTab("Séries", jScrollPane2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 649, Short.MAX_VALUE)
                    .addComponent(jLabel1))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTableSeries;
    private javax.swing.JTable jTableSports;
    // End of variables declaration//GEN-END:variables

}
